package com.v1.video.util;

import java.util.ArrayList;

import android.content.Context;
import android.content.Intent;

import com.v1.video.Constant;
import com.v1.video.activity.CibnVideoDetailActivity;
import com.v1.video.activity.LiveVRPlayerActivity;
import com.v1.video.activity.MainPageNewActivity;
import com.v1.video.activity.PaikeVideoDetailActivity2;
import com.v1.video.activity.SecondVideoDetailActivity2;
import com.v1.video.activity.ThemeDetailActivity;
import com.v1.video.activity.VideoPlayerVRActivity;
import com.v1.video.activity.WebViewActivity3;
import com.v1.video.activity.WebViewActivity4;
import com.v1.video.domain.ScenarioVideoInfo;
/**
 * 跳转页面
 * @author wangfang
 *
 */
public class TransferUtils {

	private static TransferUtils mInstance;

	private TransferUtils() {

	}

	public static TransferUtils getInstance() {
		if (mInstance == null) {
			mInstance = new TransferUtils();
		}
		return mInstance;
	}
	
	/**
	 * 
	 * @param context
	 * @param vid
	 * @param at
	 * @param title
	 * @param url
	 * @param adurl
	 * @param pic
	 * @param tid
	 * @param source
	 */
	public void transferActivity(Context context, String vid, String at,
			String title, String url, String source,String name) {
		transferActivity(context,vid,vid,at,title,url,url,"","",source,name);
	}
	
	/**
	 * 
	 * @param context
	 * @param vid
	 * @param at
	 * @param title
	 * @param url
	 * @param videourl
	 * @param adurl
	 * @param pic
	 * @param tid
	 * @param source
	 */
	public void transferActivity(Context context, String vid, String at,
			String title, String url,String adurl,String pic,String tid, String source,String name) {
		transferActivity(context,vid,tid,at,title,url,adurl,pic,"",source,name);
	}
	
	/**
	 * 
	 * @param context
	 * @param tid
	 * @param at
	 * @param title
	 * @param url
	 * @param pic
	 * @param commodityid
	 * @param source
	 */
	public void transferActivity(Context context, String tid, String at,
			String title, String url,String pic,String commodityid, String source,String name) {
		transferActivity(context,tid,tid,at,title,url,url,pic,commodityid,source,name);
	}
	
	
	/**
	 * 
	 * @param context
	 * @param vid
	 * @param tid
	 * @param at
	 * @param title
	 * @param url
	 * @param adurl
	 * @param pic
	 * @param commodityid
	 * @param source
	 */
	public void transferActivity(Context context, String vid,String tid, String at,
			String title, String url,String adurl,String pic,String commodityid, String source,String name) {
		if (Constant.VIDEO_TYPE_0.equals(at)) {

		} else if (Constant.VIDEO_TYPE_1.equals(at)) {
			transferVideoDetail(context, vid, source,name);
		} else if (Constant.VIDEO_TYPE_2.equals(at)) {

		} else if (Constant.VIDEO_TYPE_3.equals(at)) {

		} else if (Constant.VIDEO_TYPE_4.equals(at)) {

		} else if (Constant.VIDEO_TYPE_5.equals(at)) {
			transferWebView(context, title, url);
		} else if (Constant.VIDEO_TYPE_6.equals(at)) {
			transferVrVideo(context, url);
		} else if (Constant.VIDEO_TYPE_7.equals(at)) {
			transferThemeDetail(context, title, tid, pic);
		} else if (Constant.VIDEO_TYPE_8.equals(at)) {
			transferWebView(context, title, adurl);
		} else if (Constant.VIDEO_TYPE_9.equals(at)) {
			transferVrLive(context, url);
		} else if (Constant.VIDEO_TYPE_10.equals(at)) {
			transferVrPayLive(context, commodityid, title, url);
		} else if (Constant.VIDEO_TYPE_11.equals(at)) {
			transferSecondVideoDetail(context,vid);
		} else if (Constant.VIDEO_TYPE_12.equals(at)) {
			transferCibnVideoDetail(context,vid,CibnVideoDetailActivity.CIBN_TELEPLAY);
		} else if (Constant.VIDEO_TYPE_13.equals(at)) {
			transferCibnVideoDetail(context,vid,CibnVideoDetailActivity.CIBN_VARIETY);
		} else if (Constant.VIDEO_TYPE_14.equals(at)) {
			transferCibnVideoDetail(context,vid,CibnVideoDetailActivity.CIBN_FILM);
		} else if (Constant.VIDEO_TYPE_15.equals(at)) {
			transferCibnVideoDetail(context,vid,CibnVideoDetailActivity.CIBN_COMIC);
		} else {
			transferVideoDetail(context, vid, source,name);
		}
	}

	

	/**
	 * 跳转视频详情
	 * @param context
	 * @param vid
	 * @param source
	 */
	public void transferVideoDetail(Context context, String vid, String source,String name) {
		ScenarioVideoInfo videoInfo = new ScenarioVideoInfo(vid);
		if (videoInfo != null) {
			Intent intent = new Intent();
			intent.setClass(context, PaikeVideoDetailActivity2.class);
			intent.putExtra("videoInfo", videoInfo);
			intent.putExtra("source", source);
			intent.putExtra("name", name);
			context.startActivity(intent);
		}
	}

	/**
	 * 跳转网页
	 * @param context
	 * @param title
	 * @param url
	 */
	public void transferWebView(Context context, String title, String url) {
		Intent intent = new Intent();
		intent.setClass(context, WebViewActivity3.class);
		intent.putExtra("adLink", url);
		intent.putExtra(WebViewActivity3.FLAG_TITLE, title);
		context.startActivity(intent);
	}

	/**
	 * 跳转VR视频
	 * @param context
	 * @param url
	 */
	public void transferVrVideo(Context context, String url) {
		Intent intent = new Intent();
		intent.setClass(context, VideoPlayerVRActivity.class);
		ArrayList<String> listUrl = new ArrayList<String>();
		listUrl.add(url);
		intent.putStringArrayListExtra("videourl", listUrl);
		intent.putExtra("pos", 0);
		context.startActivity(intent);
	}

	/**
	 * 跳转VR直播
	 * @param context
	 * @param url
	 */
	public void transferVrLive(Context context, String url) {
		Intent intent = new Intent();
		intent.setClass(context, LiveVRPlayerActivity.class);
		intent.putExtra("videourl", url);
		context.startActivity(intent);
	}

	/**
	 * 跳转VR付费直播
	 * @param context
	 * @param id
	 * @param title
	 * @param url
	 */
	public void transferVrPayLive(Context context, String id, String title,
			String url) {
		Intent intent = new Intent();
		intent.setClass(context, WebViewActivity4.class);
		intent.putExtra("adLink", url);
		intent.putExtra("commodityid", id);
		intent.putExtra(WebViewActivity4.FLAG_TITLE, title);
		context.startActivity(intent);
	}
	
	/**
	 * 跳转主题详情
	 * @param context
	 * @param title
	 * @param tid
	 * @param imgUrl
	 */
	public void transferThemeDetail(Context context,String title, String tid, String imgUrl) {
		Intent intent = new Intent();
		intent.setClass(context, ThemeDetailActivity.class);
		intent.putExtra("title", title);
		intent.putExtra("themdId", tid);
		intent.putExtra("themeImg", imgUrl);
		context.startActivity(intent);
	}
	
	/**
	 * 跳转Cibn视频详情
	 * @param context
	 * @param videoInfo
	 * @param genre
	 */
	public void transferCibnVideoDetail(Context context,String vid,String genre) {
		Intent intent = new Intent();
		intent.setClass(context, CibnVideoDetailActivity.class);
		intent.putExtra("vid", vid);
		intent.putExtra("genre", genre);
		context.startActivity(intent);
	}
	
	/**
	 * 跳转秒评视频详情
	 * @param context
	 * @param sid
	 */
	public void transferSecondVideoDetail(Context context,String sid) {
		Intent intent = new Intent();
		intent.setClass(context, SecondVideoDetailActivity2.class);
		intent.putExtra("sid", sid);
		context.startActivity(intent);
	}
	
	/**
     * 跳转秒评列表
     */
    public void transferMainSecond(Context context) {
        Intent intent = new Intent();
        intent.setClass(context, MainPageNewActivity.class);
        intent.putExtra("tag", MainPageNewActivity.FLAG_SECOND);
        context.startActivity(intent);
    }

}
